import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import VueAxios from 'vue-axios'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
createApp(App).use(store).use(router).use(VueAxios, axios).use(ElementPlus).mount('#app')


// 在请求头中加token							
axios.interceptors.request.use(
    config => {
        // 判断是否存在token，如果存在的话，则每个http header都加上token							
        let token = sessionStorage.getItem('token')

        if (!config.headers.hasOwnProperty('token') && token) {

            config.headers.Authorization = "Bearer " + token;						//必须加上Bearer	
        }
        return config;
    },
    error => {
        _this.$router.push("/");
        returnPromise.reject(error);
    });